import java.util.Random;
import java.util.Scanner;

public class Lab_01 {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int correctCount = 0; // 正确题数

        System.out.println("100以内加减法口算习题（共50道）");
        for (int i = 1; i <= 50; i++) {
            int a = random.nextInt(100); // 0-99随机数
            int b = random.nextInt(100);
            boolean isAdd = random.nextBoolean(); // 随机决定加减

            // 确保减法结果非负
            if (!isAdd && a < b) {
                int temp = a;
                a = b;
                b = temp;
            }

            // 输出题目并接收答案
            System.out.print("第" + i + "题：" + a + (isAdd ? "+" : "-") + b + "=");
            int userAnswer = scanner.nextInt();
            int correctAnswer = isAdd ? (a + b) : (a - b);

            // 验证答案
            if (userAnswer == correctAnswer) {
                System.out.println("正确！");
                correctCount++;
            } else {
                System.out.println("错误，正确答案是：" + correctAnswer);
            }
        }

        System.out.println("答题结束！共50题，正确" + correctCount + "题，正确率：" + (correctCount * 2) + "%");
        scanner.close();
    }
}